#ifndef FRMUDPCLIENT_H
#define FRMUDPCLIENT_H

#include <QWidget>
#include <QtNetwork>
#include <opencv2/opencv.hpp>
#include "src/player/images/UDPRecieve.h"
#include <QKeyEvent>
#include <QObject>
#include "src/control/keybordcontrol/keywidget.h"
#include "src/control/keybordcontrol/KeyBoardManger.h"
#include "../../player/images/ImageReceiver.h"
#include "../../sigcmd/mqttclient.h"
#include <map>
#include <QString>
namespace Ui {
class frmUdpClient;
}

class frmUdpClient : public QWidget
{
Q_OBJECT

public:
    explicit frmUdpClient(QWidget *parent = 0);
    ~frmUdpClient();

protected:
    bool eventFilter(QObject *watched, QEvent *event);

private slots:
    void initForm();
    void initConfig();
    void saveConfig();
    void initTimer();
    void append(int type, const QString &data, bool clear = false);
    void error();
    void readData();
    void sendData(const QString &ip, int port, const QString &data);
    void on_btnSave_clicked();
    void on_btnClear_clicked();
    void on_btnSend_clicked();
public slots:
    void onDisplayImage(const cv::Mat &image);
    //接收导盲犬的基础数据
    void onRecieveVBasidDatas(const QString &msg);
private:
    /***
     * @brief设置订阅和发布topic
     * @param[in] sigCmdTopic
     * @param[in] picRecTopic
     **/
    void setTopic(const QString &sigCmdTopic, const QString &picRecTopic);
private:
    Ui::frmUdpClient *ui;

    QUdpSocket *socket;
    QTimer *timer;
    std::shared_ptr<CImageReceiver>  m_pReceiver; //接收图片
    CMqttClient *m_pMqqtClient;

    std::map<QString, QString> m_baseMap;  //导盲犬基础数据 Sn和Ip
};

#endif // FRMUDPCLIENT_H
